package indigo.captcha.image;

import com.jhlabs.image.OffsetFilter;
import com.jhlabs.image.TransformFilter;

public class OffsetDeformer extends ThreadLocalFilterDeformer<OffsetFilter> {
	private final int height;
	private final int maxFontSize;

	public OffsetDeformer(int height, int maxFontSize) {
		super();
		this.height = height;
		this.maxFontSize = maxFontSize;
	}

	@Override
	protected OffsetFilter createFilter() {
		OffsetFilter filter = new OffsetFilter();
		filter.setEdgeAction(TransformFilter.CLAMP);
		filter.setXOffset(0);
		filter.setYOffset((height - maxFontSize) / 2);
		return filter;
	}

	@Override
	protected void prepareFilter(OffsetFilter filter) {
		// noop
	}
}
